import $qs from 'qs'
import { axios, VueAxios } from '@/utils/request'
import store from '@/store'
/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function companyInfo() {
  return axios({
    url: '/school/setting/get-company-info',
    method: 'post',
  })
}
// 
export function loginFunc(params) {
  return axios({
    url: '/school/users/login',
    method: 'post',
    data: $qs.stringify(params)
  })
}
export function getInfo(params) {
  return axios({
    url: '/school/users/show',
    method: 'post',
    data: $qs.stringify(params)
  })
}

export function uploadPic(params) {
  params.append('school_id', store.state.user.school)
  return axios({
    url: '/school/images/upload',
    method: 'post',
    data: params
  })
}

export function changeUserInfo(parameter, id) {
  return axios({
    url: '/school/users/' + id + '/update',
    method: 'post',
    data: parameter
  })
}

// export function getInfo () {
//   return axios({
//     url: '/user/info',
//     method: 'get',
//     headers: {
//       'Content-Type': 'application/json;charset=UTF-8'
//     }
//   })
// }

// export function getCurrentUserNav (token) {
//   return axios({
//     url: '/user/nav',
//     method: 'get'
//   })
// }

export async function refreshT() {
  return axios({
    url: '/school/users/refresh',
    method: 'post',
  })
}

//找回密码
//获取图形验证码
export function getPicCaptcha(parameter) {
  return axios({
    url: '/school/users/captcha-image',
    method: 'post',
    data: parameter
  })
}
//发送短信
export function sendSms(parameter) {
  return axios({
    url: '/school/users/send-sms',
    method: 'post',
    data: parameter
  })
}
//找回密码
export function findPwd(parameter) {
  return axios({
    url: '/school/users/retrieve-password',
    method: 'post',
    data: parameter
  })
}
// /**
//  * get user 2step code open?
//  * @param parameter {*}
//  */
// export function get2step (parameter) {
//   return axios({
//     url: api.twoStepCode,
//     method: 'post',
//     data: parameter
//   })
// }
